home *** CD-ROM | disk | FTP | other *** search
/ develop, the CD; issue 1 / Apple_Develop_1989.bin / Compatibility / Printing / PrintRecord Saving next >
Text File  |  1989-06-14  |  3KB  |  50 lines

  1.  
  2.  
  3.  
  4.     The best method for saving the print record is to save it as a resource in your document's resource fork.  Since the print record is already pointed to by a valid handle, creating a resource is easy.  Here are the steps required:
  5.  
  6.         1.  Save the refNum returned by CurResFile.
  7.  
  8.         2.  Make sure the resource fork of the document file is opened
  9.             using OpenResFile(IM I-115).
  10.  
  11.         2.  Now that you have a place to put the resource, you must get the
  12.             resource manager to create it for you.  First, pick a type and ID
  13.             for your resource.  You can use the Unique ID function(IM I-121) to
  14.             generate the ID.  Next, call the AddResource procedure(IM I-124).
  15.             This procedure takes four parameters:
  16.  
  17.                 Parameter   Type        What to Pass
  18.                 ---------   ----        ------------
  19.                 theData     Handle      The handle to the currently valid print
  20.                                         record.
  21.                 theType     ResType     The four character resource type you 
  22.                                         have chosen.
  23.                 theID       INTEGER     The ID returned from the UniqueID 
  24.                                         function.
  25.                 name        Str255      The name for this resource.  This is 
  26.                                         optional, use '' if you have no name.
  27.  
  28.         3.  Next call WriteResource(IM I-125), and UpdateResFile(IM I-125) to 
  29.             make sure the new resource gets saved into the file.
  30.  
  31.         4.  Reset the currently selected file back to whatever it was before
  32.             you began the save using UseResFile(IM I-117).
  33.  
  34.     The important things to keep in mind when doing this are:
  35.  
  36.         1.  You should make your resource type something different than those 
  37.             used by the Print Manager.  This will prevent the Print Manager 
  38.             from getting confused and grabbing the wrong resource.  Types to 
  39.             avoid include; 'PREC', 'PDEF', and 'POST'.
  40.  
  41.         2.  Don't make any assumptions about the size of the print record.  If 
  42.             you really need to know the size, use GetHandleSize.  This way, if 
  43.             the record gets bigger in the future, your code will still work.
  44.  
  45.         3.  Make sure to pass the record that you get from your document to 
  46.             PrValidate before using it.  This will make sure that it get's 
  47.             updated if any changes are made to the structure or contents of the 
  48.             record since it was saved.
  49.  
  50.